<template>
  <div>
    <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
      <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
      style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
      <a style="margin-left: 24px" @click="onClearSelected">清空</a>
    </div>

    <a-table
      ref="table"
      size="middle"
      :scroll="{x:true}"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="tableData"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys,  onChange: onSelectChange}"
      class="j-table-force-nowrap"
      @change="handleTableChange">

      <template slot="htmlSlot" slot-scope="text">
        <div v-html="text"></div>
      </template>
      <template slot="imgSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
        <img v-else :src="getImgView(text)" height="25px" alt=""
             style="max-width:80px;font-size: 12px;font-style: italic;" />
      </template>
      <template slot="fileSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
        <a-button
          v-else
          :ghost="true"
          type="primary"
          icon="download"
          size="small"
          @click="downloadFile(text)">
          下载
        </a-button>
      </template>

      <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
    </a-table>
  </div>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import AchExaminationPaperModal from './modules/AchExaminationPaperModal'
import { getAchExamProjectItemByPaperId, getAchExamProjectItemStandard } from '@api/achievementCommonAPI'
import { getAction, deleteAction, postAction } from '@api/manage'

export default {
  name: 'AchExaminationPaperListTables',
  mixins: [JeecgListMixin, mixinDevice],
  data() {
    return {
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '科目',
          align: 'center',
          dataIndex: 'subjectName'
        },
        {
          title: '试卷编码',
          align: 'center',
          dataIndex: 'examinationPaperCode'
        },
        {
          title: '试卷名称',
          align: 'center',
          dataIndex: 'examinationPaperName'
        },
        {
          title: '所属考试',
          align: 'center',
          dataIndex: 'examinationName'
        },
        {
          title: '试卷类型',
          align: 'center',
          dataIndex: 'examinationPaperTtype_dictText'
        },
        {
          title: '试卷来源',
          align: 'center',
          dataIndex: 'examinationPaperSource'
        },
        {
          title: '满分',
          align: 'center',
          dataIndex: 'examinationPaperFullMarks'
        },
        {
          title: '及格分',
          align: 'center',
          dataIndex: 'examinationPaperPassMarks'
        },
        {
          title: '考试时间',
          align: 'center',
          dataIndex: 'examinationPaperTestTime',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '考试时长(分钟)',
          align: 'center',
          dataIndex: 'examinationPaperDuration'
        },
        {
          title: '是否启用',
          align: 'center',
          dataIndex: 'izOpen_dictText'
        },
        {
          title: '所属部门',
          align: 'center',
          dataIndex: 'sysOrgName'
        },
        // {
        //   title:'创建人',
        //   align:"center",
        //   dataIndex: 'createBy'
        // },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/achexaminationpaper/achExaminationPaper/list',
        volist: '/achexaminationpaper/achExaminationPaper/list'
      },
      tableData: []
    }
  },
  methods: {
    getOrderMain(examinationId) {
      if (examinationId != null) {
        this.queryParam.examinationId = examinationId
        getAction(this.url.volist, this.queryParam).then(res => {
          if (res.code === 200) {
            this.tableData = res.result.records
          } else {
            this.$message.error(res.message)
          }
        })
      }

    }
  }
}
</script>

<style scoped>

</style>